import { Component, OnInit } from '@angular/core';

// 引入ActivatedRoute模块
import { ActivatedRoute } from '@angular/router';



@Component({
  selector: 'app-router',
  templateUrl: './router.component.html',
  styleUrls: ['./router.component.css']
})
export class RouterComponent implements OnInit {
// 声明ActivatedRoute
  constructor(public myactiveroute:ActivatedRoute) { }

  ngOnInit(): void {
    console.log(this.myactiveroute,'当前激活路由')
    //返回值是一个RxJS对象，需使用 subscribe 调用
    // 动态路由
    this.myactiveroute.params.subscribe((res) => {
      console.log(res,'动态路由传参')
    })
  }

}
